<?php

/**
 * Docente filter form.
 *
 * @package    sistema_estadisticas
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class DocenteFormFilter extends BaseDocenteFormFilter
{

	public function configure()
	{
		unset($this['comision_academica_list']);

		$this->widgetSchema['identification'] = new sfWidgetFormFilterInput(array('with_empty' => false));
		$this->widgetSchema['first_name'] = new sfWidgetFormFilterInput(array('with_empty' => false));
		$this->widgetSchema['last_name'] = new sfWidgetFormFilterInput(array('with_empty' => false));
		$this->widgetSchema['username'] = new sfWidgetFormFilterInput(array('with_empty' => false));
		$this->widgetSchema['email_address'] = new sfWidgetFormFilterInput(array('with_empty' => false));

		$this->validatorSchema['identification'] = new sfValidatorPass();
		$this->validatorSchema['first_name'] = new sfValidatorPass();
		$this->validatorSchema['last_name'] = new sfValidatorPass();
		$this->validatorSchema['email_address'] = new sfValidatorPass();
		$this->validatorSchema['username'] = new sfValidatorPass();
	}

	public function addIdentificationColumnQuery(Doctrine_Query $query, $field, $values)
	{
		if (is_array($values) && $values['text'])
		{
			$query->addWhere('u.identification LIKE ?', $values['text'] . '%');
		}
	}

	public function addFirstNameColumnQuery(Doctrine_Query $query, $field, $values)
	{
		if (is_array($values) && $values['text'])
		{
			$query->addWhere('u.first_name LIKE ?', $values['text'] . '%');
		}
	}

	public function addLastNameColumnQuery(Doctrine_Query $query, $field, $values)
	{
		if (is_array($values) && $values['text'])
		{
			$query->addWhere('u.last_name LIKE ?', $values['text'] . '%');
		}
	}

	public function addUsernameColumnQuery(Doctrine_Query $query, $field, $values)
	{
		if (is_array($values) && $values['text'])
		{
			$query->addWhere('u.username LIKE ?', $values['text'] . '%');
		}
	}

	public function addEmailAddressColumnQuery(Doctrine_Query $query, $field, $values)
	{
		if (is_array($values) && $values['text'])
		{
			$query->addWhere('u.email_address LIKE ?', $values['text'] . '%');
		}
	}

}
